import Dialog from "./Dialog.vue";
import {createApp, h} from "vue";

export const openDialog = (options) => {
    const {title, content,closeOnClickOverlay,ok,cancel} = options
    const div = document.createElement('div')
    document.body.appendChild(div)
    // createApp(Dialog).mount(div)
    const close = () => {
        //@ts-ignore
        app.unmount(div)
        div.remove()
    }
    const app = createApp({
        render() {
            return h(Dialog, {visible: true,
                ok,cancel,closeOnClickOverlay,'onUpdate:visible': (newVisible) => {
                        if (!newVisible) {close()}
                    }},{title, content}
                )
        }
    })
    app.mount(div)
}
